package com.guide.framework.datasource;

import java.sql.SQLException;
import java.util.Properties;

import javax.sql.DataSource;

import org.apache.ibatis.mapping.DatabaseIdProvider;

public class DynamicDatabaseIdProvider implements DatabaseIdProvider {

	@Override
	public void setProperties(Properties p) {
		throw new RuntimeException("DynamicDatabaseIdProvider Not Support setProperties.");
	}

	@Override
	public String getDatabaseId(DataSource dataSource) throws SQLException {
		if(dataSource != null && dataSource instanceof DynamicDataSource) {
			return ((DynamicDataSource)dataSource).getDatabaseProductName();
		}
		return null;
	}

}
